<template>
    <div class="goodsCat" style="margin-left: 10px;margin-top: 15px">
          <el-button type="primary" @click="goodsCatAddVisible = true">新增分类</el-button>
      <el-table
        :data="goodsCatData"
        v-loading="tableLoad"
        style="width: 100%;margin-top: 10px">
        <el-table-column
          prop="id"
          label="序号"
          >
        </el-table-column>
        <el-table-column
          prop="name"
          label="分类名称"
         >
        </el-table-column>
        <el-table-column
          prop="sort_num"
          label="排序"
         >
        </el-table-column>

        <el-table-column label="操作" align="center"
                         class-name="small-padding fixed-width">
          <template slot-scope="{row,$index}">
            <el-button type="primary" size="mini" @click="goodsCatUpdate(row)">
              编辑
            </el-button>

            <el-button size="mini" type="danger" @click="goodsCatDelete(row.id)">
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <!--  分类新增 start   -->
      <el-dialog title="分类新增" :visible.sync="goodsCatAddVisible" width="20%">
        <el-form :model="goodsCatInfo">
          <el-form-item label="商品名称">
            <el-input style="width: auto" v-model="goodsCatInfo.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="分类排序">
            <el-input type="number" style="width: auto" v-model="goodsCatInfo.sort_num" autocomplete="off" placeholder="序号越小 位置越前"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="goodsCatAddVisible = false">取 消</el-button>
          <el-button type="primary" @click="goodsCatAdd()">确 定</el-button>
        </div>
      </el-dialog>
      <!--  分类新增 end   -->

      <!--  分类新增 start   -->
      <el-dialog title="分类编辑" :visible.sync="goodsCatAddVisible" width="20%">
        <el-form :model="goodsCatInfoTemp">
          <el-form-item label="分类名称">
            <el-input style="width: auto" v-model="goodsCatInfoTemp.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="分类排序">
            <el-input type="number" style="width: auto" v-model="goodsCatInfoTemp.sort_num" autocomplete="off" placeholder="序号越小 位置越前"></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="goodsCatAddVisible = false">取 消</el-button>
          <el-button type="primary" @click="goodsCatUpdateSave()">确 定</el-button>
        </div>
      </el-dialog>
      <!--  分类新增 end   -->
    </div>
</template>

<script src="./_goodsCat.js" lang="js"></script>
<style src="./_goodsCat.scss" lang="scss" scoped></style>
